<template>
	<div class="school">
		<h2>我是School组件</h2>
		<h3>名称：{{name}}，地址：{{addresss}}</h3>
		<h3 v-if="nl">我哥哥(Person)给我的年龄是：{{nl}}</h3>
	</div>
</template>

<script>
	export default {
		name:'School',
		data() {
			return {
				name:'尚硅谷',
				addresss:'宏福科技园',
				nl:0
			}
		},
		methods: {
			test(value){
				console.log('x身上的haha事件被触发了，引起了test回调的执行，test方法在School组件里',value)
				this.nl = value
			}
		},
		mounted() {
			this.$bus.$on('haha',this.test) //绑定事件并指定事件的回调
		},
	}
</script>

<style scoped>
	.school{
		background-color: green;
		padding: 20px;
	}
</style>